package com.newyear.FitnessEquipmentManager.service.impl;

import com.newyear.FitnessEquipmentManager.dao.FitnessEquipmentDao;
import com.newyear.FitnessEquipmentManager.entity.FitnessEquipment;
import org.apache.ibatis.session.SqlSession;
import com.newyear.FitnessEquipmentManager.service.FitnessEquipmentService;
import com.newyear.FitnessEquipmentManager.utils.MyBatisUtil;

import java.util.List;

/**
 * @author 吴阳基
 * @datetime 2023/11/11 14:45
 */
public class FitnessEquipmentServiceImpl implements FitnessEquipmentService {

    @Override
    public List<FitnessEquipment> list() {
        SqlSession sqlSession = MyBatisUtil.createSqlSession();
        return sqlSession.getMapper(FitnessEquipmentDao.class).list();

    }

    @Override
    public int add(FitnessEquipment fitnessEquipment) {
        SqlSession sqlSession = MyBatisUtil.createSqlSession();
        int add = sqlSession.getMapper(FitnessEquipmentDao.class).add(fitnessEquipment);
        sqlSession.commit();
        return add;
    }

    @Override
    public int delete(int id) {
        SqlSession sqlSession = MyBatisUtil.createSqlSession();
        int delete = sqlSession.getMapper(FitnessEquipmentDao.class).delete(id);
        sqlSession.commit();
        return delete;
    }
}
